//
//  GB_HelpViewController.m
//  MELive
//
//  Created by 郭宝 on 16/10/22.
//  Copyright © 2016年 郭宝. All rights reserved.
//

#import "GB_HelpViewController.h"
#import <WebKit/WebKit.h>
#import "Macro.h"
#import "UIView+Extension.h"
@interface GB_HelpViewController () <WKUIDelegate, WKNavigationDelegate>
@property (nonatomic, strong) WKWebView *webView;
@property (nonatomic, strong) UIImageView *tom;
@end

@implementation GB_HelpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = _itemTitle;
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"navi_follow_icon"] imageWithRenderingMode:1] style:UIBarButtonItemStylePlain target:self action:@selector(didBackAction:)];
    

    self.webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.webView.UIDelegate = self;
    self.webView.navigationDelegate = self;
    [self.view addSubview:self.webView];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://web.me.yy.com/s/static/share/help/help-list.html?uid=203995915&fromlive=0"]]];
    
}
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
    NSMutableArray  *arrayM=[NSMutableArray array];
    for (int i=1; i<= 55; i++) {
        [arrayM addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Me_icon_loading%d",i]]];
    }
    self.tom = [[UIImageView alloc] initWithFrame:CGRectMake(20, 80, 100, 100)];
    _tom.centerX = self.view.centerX;
    _tom.centerY = self.view.centerY-64;
    [self.view addSubview:self.tom];
    //设置动画数组
    [self.tom setAnimationImages:arrayM];
    //设置动画播放次数
    [self.tom setAnimationRepeatCount:0];
    //设置动画播放时间
    [self.tom setAnimationDuration:40*0.075];
    //开始动画
    [self.tom startAnimating];
}
- (void)didBackAction:(UIButton *)button {
    self.navigationController.navigationBar.hidden = YES;
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    self.tom.hidden = YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
